package com.example.demo.controller;

import com.example.demo.manage.KafkaConsumerDemo;
import com.example.demo.manage.KafkaProducer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: wn
 * @Date: 2021/8/3 14:42
 * @Version 1.0
 * @Note
 */
@Api(tags = "kafka测试")
@RestController
@RequestMapping("/kafka")
public class KafkaController {

    @Autowired
    private KafkaProducer kafkaProducer;

    @Autowired
    private KafkaConsumerDemo kafkaConsumerDemo;

    @ApiImplicitParam(name = "msg",value = "消息",required = true)
    @ApiOperation(value = "发送消息")
    @GetMapping("/createMsg")
    public void createMsg(String msg) {
        kafkaProducer.sendUserMessage(msg);
    }

    @GetMapping("/readMsg")
    public void readMsg() {
        kafkaConsumerDemo.consume();
    }
}
